<?php
class model_home extends base_model{
    # region 广告分类
	public function mod_advs_category(){
	    $sql = "SELECT `id`,`title` FROM `@@adv_category`";
	    return $this->db->query($sql,3);
    }
    # endregion

    # region 充值、提现信息提示
    public function mod_tip(){
	    $result = $this->redisGet('system_tip');
	    if(!$result) {
            $begintimes = time() - 10;
            $endtimes = $begintimes + 86400;
            $where = "actiontime BETWEEN {$begintimes} AND {$endtimes} AND usertype IN(1,2) AND state=0 AND `paywayid`<>2";
            $sql = "SELECT COUNT(id) AS _TOTAL FROM `@@users_recharge` WHERE {$where}";
            $recharge = $this->db->query($sql, 2);

            $begintimes = time() - 600;
            $endtimes = $begintimes + 86400;
            $where = "actiontime BETWEEN {$begintimes} AND {$endtimes} AND usertype IN(1,2) AND state=0 AND `paywayid`=2 AND `transfername`<>''";
            $sql = "SELECT COUNT(id) AS _TOTAL FROM `@@users_recharge` WHERE {$where}";
            $recharge2 = $this->db->query($sql, 2);

            $where = "cashtime BETWEEN {$begintimes} AND {$endtimes} AND usertype IN(1,2) AND state=0";
            $sql = "SELECT COUNT(id) AS _TOTAL FROM `@@users_cash` WHERE {$where}";
            $cash = $this->db->query($sql, 2);

            $result = array(
                'recharge' => $recharge['_TOTAL'] + $recharge2['_TOTAL'],
                'cash' => $cash['_TOTAL'],
            );

            $this->redisSetEx('system_tip', $result,5);
        }

        return $result;
    }
    # endregion
	
}
?>